package 力扣;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

/**
 * @author yyq
 * @create 2022-06-10 20:13
 */
public class leetcode406 {
    public static void main(String[] args) {

    }
    public int[][] reconstructQueue(int[][] people) {
        Arrays.sort(people, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if(o2[0]==o1[0]){
                    return o1[1]-o2[1];
                }
                return o2[0]-o1[0];
            }
        });
        ArrayList<int[]> list=new ArrayList<>();
        for (int i=0;i<people.length;i++){
            int postion=people[i][1];
            list.add(postion,people[i]);
        }
        return  list.toArray(new int[people.length][people[0].length]);
    }
}
